#include "threadnfcreader.h"

SupportThreadNfc *supportWorker;

void cardAbsent(void *param)
{
    supportWorker->cardAbsent(param);
}

void cardPresent(void *param)
{
    supportWorker->cardPresent(param);
}

const NfcHandlerFp _cbfc[] =
{		cardAbsent,
        cardPresent
};

ThreadNfcReader::ThreadNfcReader(QObject *parent) :
    QThread(parent)
{
    mlsNfcParam_t param;
    param.cardStatusChange = False;
    param.isTransparentMode = False;
    param._cbCardAbsent  = _cbfc[0];
    param._cbCardPresent = _cbfc[1];
    supportWorker = new SupportThreadNfc();
    connect(supportWorker,SIGNAL(SignalCardPresentSupport()),this,SLOT(SlotCardPresentReplay()));
    connect(supportWorker,SIGNAL(SignalCardAbsentSupport()),this,SLOT(SlotCardAbsentReplay()));
    mlsNfcInit(&param);
}

/*function reimplement for thread task*/
void ThreadNfcReader::run()
{
    while (1)
    {
       mlsNfcUpdate(NULL);
       usleep(100000);
    }
}

/*slot handle to repeat signal card absent or present from support worker*/
void ThreadNfcReader::SlotCardPresentReplay()
{
    emit SignalCardPresent();
}

/*slot handle to repeat signal card absent or present from support worker*/
void ThreadNfcReader::SlotCardAbsentReplay()
{
    emit SignalCardAbsent();
}

